package com.rysima.wujiansima.demo;

import java.util.Comparator;
import java.util.Set;
import java.util.TreeSet;

public class Demo {
    public static void main(String[] args) {
        Student stu = new Student("胡涵",56,66,66);
        Student stu2 = new Student("胡涵",56,66,66);
        Student stu1 = new Student("物件",58,66,66);
        Set<Student> set = new TreeSet<>(new Comparator<Student>() {
            @Override
            public int compare(Student o1, Student o2) {
                int result = o2.getTotalScore() - o1.getTotalScore();
                int chinese = result == 0?o2.getChinese() - o1.getChinese(): result;
                int math = chinese == 0?o2.getMath() - o1.getMath():chinese;
                return math;
            }
        });
        set.add(stu);
        set.add(stu1);
        int i = stu.hashCode();
        int i1 = stu2.hashCode();
        System.out.println(i1);
        System.out.println(i);
        System.out.println(set);
    }
}
